<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('鸡出库列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<div class="btn-group " style="margin: 0px auto;display: table;" role="group">

					<button type="button" class="top-link btn-sm btn-white">农事</button>
					<button type="button" class="top-link btn-sm btn-white">鸡入库</button>
					<button type="button" class="top-link btn-sm btn-primary">鸡出库</button>
				</div>
				<!--<form id="formId">
					<input ="cforder_id" th:value=""/>
					<div class="select-list">
						<ul>
							<li>
								菜房订单id：<input type="text" name="cforderId"/>
							</li>

							<li>
								出库日期：<input type="text" name="outputTime"/>
							</li>

							<li>
								需求数量（只：<input type="text" name="requestAmount"/>
							</li>

							<li>
								供应数量（只）：<input type="text" name="outputAmount"/>
							</li>

							<li>
								供应大鸡数量（只）：<input type="text" name="outputAmountBig"/>
							</li>

							<li>
								供应小鸡数量（只）：<input type="text" name="outputAmountLittle"/>
							</li>

							<li>
								出库类型 字典：<input type="text" name="outputType"/>
							</li>

							<li>
								抓鸡时间：<input type="text" name="catchTime"/>
							</li>

							<li>
								母鸡状态 1:正常 2：不正常：<input type="text" name="chickenStatus"/>
							</li>

							<li>
								宰杀时间：<input type="text" name="killTime"/>
							</li>

							<li>
								宰杀后成品母鸡标准 1：健康 2：不健康：<input type="text" name="isHealthy"/>
							</li>

							<li>
								宰杀人员：<input type="text" name="butcher"/>
							</li>

							<li>
								菜房接收时间：<input type="text" name="receiveTime"/>
							</li>

							<li>
								菜房接收人员：<input type="text" name="receiver"/>
							</li>

							<li>
								出库经手人：<input type="text" name="outputUser"/>
							</li>

							<li>
								创建者：<input type="text" name="createBy"/>
							</li>

							<li>
								创建时间：<input type="text" name="createTime"/>
							</li>

							<li>
								备注：<input type="text" name="remark"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>-->
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncOutputChicken:add">
					<i class="fa fa-plus"></i> 新增
				</a>
				<a class="btn btn-warning" onclick="confirmTable();">
					<i class="fa fa-send"></i> 确认
				</a>
				<a class="btn btn-primary " onclick="openOrder();">
					<i class="fa fa-table"></i> 出库单管理
				</a>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<h3 style="width:100%;text-align:center;">存栏数量：<span  style="color: #1c84c6;" th:text="${chickStackAamount}">23</span><span style="color: #1c84c6;">只</span> &nbsp;&nbsp; 主饲料库存：<span style="color: #1c84c6;" th:text="${zFfeed}">23</span><span style="color: #1c84c6;">kg</span>  &nbsp;&nbsp; 辅饲料库存：<span style="color: #1c84c6;" th:text="${fFfeed}">23</span><span style="color: #1c84c6;">kg</span></h3>
				<h3>当天工作内容：</h3>
				<table id="bootstrap-table-1" data-mobile-responsive="true"></table>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<h3>出库订单表：</h3>
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
			<div class="bottom-btns"></div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:ncOutputChicken:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:ncOutputChicken:remove')}]];
        var prefix = ctx + "system/ncOutputChicken";

        $(function() {
            //出库类型
            var outputType=[[${@dict.getType('outputType')}]];
            //鸡状态
            var chickenStatus=[[${@dict.getType('chickenStatus')}]];
            //宰杀后母鸡标准
            var isHealthy=[[${@dict.getType('isHealthy')}]];
            //初始化上面的table
            var options1 = {
                url: prefix + "/selectChicken?cforderStatus=7&status=2",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "鸡出库",
                showExport: false,
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                sortName:'requestTime',
                sortOrder:'desc',
                id:"bootstrap-table-1",
                columns: [{
                    checkbox: true
                },
                    {
                        field : 'cforderId',
                        title : '订单id',
                        visible: false
                    },
                    {
                        title: '序号',
                        formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                        }
                    },
                    /*{
                        field : 'cforderId',
                        title : '菜房订单id',
                        sortable: true
                    },
                    {
                        field : 'outputTime',
                        title : '出库日期',
                        sortable: true
                    },*/
                        {
                            field : 'cropNameCn',
                            title : '产品名称',
                            sortable: true
                        },
                    {
                        field : 'requestAmount',
                        title : '需求数量（只）',
                        sortable: true
                    },
                    {
                        field : 'requestTime',
                        title : '需求时间',
                        sortable: true
                    },
                    /*{
                       field : 'requestAmount',
                       title : '供应数量（只）',
                       sortable: true
                   },
                  {
                       field : 'outputAmountBig',
                       title : '供应大鸡数量（只）',
                       sortable: true
                   },
                   {
                       field : 'outputAmountLittle',
                       title : '供应小鸡数量（只）',
                       sortable: true
                   },
                   {
                       field : 'outputType',
                       title : '出库类型 字典',
                       sortable: true
                   },
                   {
                       field : 'catchTime',
                       title : '抓鸡时间',
                       sortable: true
                   },
                   {
                       field : 'chickenStatus',
                       title : '母鸡状态 1:正常 2：不正常',
                       sortable: true
                   },
                   {
                       field : 'killTime',
                       title : '宰杀时间',
                       sortable: true
                   },
                   {
                       field : 'isHealthy',
                       title : '宰杀后成品母鸡标准 1：健康 2：不健康',
                       sortable: true
                   },
                   {
                       field : 'butcher',
                       title : '宰杀人员',
                       sortable: true
                   },
                   {
                       field : 'receiveTime',
                       title : '菜房接收时间',
                       sortable: true
                   },
                   {
                       field : 'receiver',
                       title : '菜房接收人员',
                       sortable: true
                   },
                   {
                       field : 'outputUser',
                       title : '出库经手人',
                       sortable: true
                   },
                   {
                       field : 'createBy',
                       title : '创建者',
                       sortable: true
                   },
                   {
                       field : 'createTime',
                       title : '创建时间',
                       sortable: true
                   },*/
                    {
                        field : 'remark',
                        title : '备注',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return $.table.tooltip(value);
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];

                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"  onclick="enter(\'' + row.cforderId+ '/'+row.requestAmount+'\' )"><i class="fa fa-edit"></i>确认</a> ');
 /*                               actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.cforderId + '\')"><i class="fa fa-remove"></i>删除</a>');*/

                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options1);
            //初始化下面的table
            var options = {
                url: prefix + "/list?outputStatus=2",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "鸡出库",
                showExport: false,
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                sortName:'outputTime',
                sortOrder:'desc',
                columns: [{
		            checkbox: true
		        },
				{
					field : 'outputId', 
					title : '入库id',
					visible: false
				},
                    {
                        title: '序号',
                        formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                        }
                    },
				/*{
					field : 'cforderId', 
					title : '菜房订单id',
					sortable: true
				},*/
				{
					field : 'outputTime', 
					title : '出库日期',
					sortable: true
				},
				{
					field : 'requestAmount', 
					title : '需求数量（只）',
					sortable: true
				},
				{
					field : 'outputAmount', 
					title : '供应数量（只）',
					sortable: true
				},
				{
					field : 'outputAmountBig', 
					title : '供应大鸡数量（只）',
					sortable: true
				},
				{
					field : 'outputAmountLittle', 
					title : '供应小鸡数量（只）',
					sortable: true
				},
                    {
                        field : 'outputWeight',
                        title : '重量（kg）',
                        sortable: true
                    },
				{
					field : 'outputType', 
					title : '出库类型',
					sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(outputType, value);
                    }
				},
				{
					field : 'catchTime', 
					title : '抓鸡时间',
					sortable: true
				},
				{
					field : 'chickenStatus', 
					title : '母鸡状态',
					sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(chickenStatus, value);
                    }
				},
				{
					field : 'killTime', 
					title : '宰杀时间',
					sortable: true
				},
				{
					field : 'isHealthy', 
					title : '宰杀后成品母鸡标准',
					sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isHealthy, value);
                    }
				},
				{
					field : 'butcher', 
					title : '宰杀人员',
					sortable: true
				},
				{
					field : 'receiveTime', 
					title : '菜房接收时间',
					sortable: true
				},
				{
					field : 'receiver', 
					title : '菜房接收人员',
					sortable: true
				},
				{
					field : 'outputUser', 
					title : '出库经手人',
					sortable: true
				},
				/*{
					field : 'createBy', 
					title : '创建者',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},*/
				{
					field : 'remark', 
					title : '备注',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.outputId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.outputId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
            var btns = [
                {
                    name: "宰杀管理",
                    url: ctx + 'system/ncZaisha',
                    id: 'Zaisha-work'
                },
                {
                    name: "主饲料",
                    url: ctx + 'system/ncChickenFeed?feedType=1',
                    id: 'Feed-work'
                },
                {
                    name: "辅饲料",
                    url: ctx + 'system/ncChickenFeed2?feedType=2',
                    id: 'Feed2-work'
                },
                {
                    name: "消毒记录",
                    url: ctx + 'system/ncChickenDisinfection?',
                    id: 'Disinfection-work'
                },
                {
                    name: "兽医请求",
                    url: ctx + 'system/ncChickenZhenliaoLogs',
                    id: 'zhenliao-work'
                },
				{
					name: "所有诊疗记录",
					url: ctx + 'system/ncChickenZhenliaoLogs/allZhenliao',
					id: 'zhenliaojilu'
				},
                {
                    name: "诊疗单",
                    url: ctx +'system/ncOrder?orderType=17',
                    id: 'Depot-work'
                },
                {
                    name: "日报表",
                    url: ctx + 'system/ncChickenDayCensus',
                    id: 'chicken_day'
                },
                {
                    name: "月报表",
                    url: ctx + 'system/ncChickenMonthCensus',
                    id: 'chicken_month'
                },
                {
                    name: '工作记录',
                    url: ctx + 'system/ncNormalWorks?workType=9',
                    id: 'normal-work'
                },
                {
                    name: '所有出库',
                    url: ctx + 'system/ncOutputChicken/ncOutputChickenAll',
                    id: 'ncOutputChickenAll'
                }

            ]
            addBtns(btns);
            $('.top-link').click(function () {
                var index = $(this).index();
                switch (index) {
                    case 0:
                        window.location.href = ctx + 'system/ncChickenWorkNotice';
                        return;
                    case 1:
                        window.location.href = ctx + 'system/ncInputChicken';
                        return;
                    case 2:
                        window.location.reload();
                        return;
                }
            })
        });
        function enter(id){

            var url = prefix + '/enter/'+id;
            $.modal.open("鸡舍出库确认单", url);
        }
        /*表单确认*/
        function confirmTable() {
            var confirmTable = prefix + "/confirmTable";
            var data = $('#bootstrap-table').bootstrapTable('getData');
            if (data && data.length > 0) {

                $.modal.confirm("确认生成订单吗？", function () {
                    var ids = [];
                    $(data).each(function (i, e) {
                        ids.push(e.outputId);
                    });
                    var ids_str = ids.join(",");
                    myPost(confirmTable, {ids: ids_str},
                        function (data) {

                            if (data.code == 0) {
                                layer.msg("提交成功")
                            } else {
                                layer.msg(data.msg);
                            }
                            reload()
                        }, function (e) {
                            layer.msg("确认失败!");
                            reload()
                        })

                })
            } else {
                layer.msg("未发现数据!")
            }

        }
        /*打开检测记录单*/
        function openOrder() {

            var url = ctx + 'system/ncOrder?orderType=13 ';

            $.modal.openTab("鸡舍出库记录单", url);
        }
        function reload() {
            $.table.refresh();
        }
        setTitle("鸡舍管理-鸡出库",false)
    </script>
</body>
</html>